﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Localization;

namespace Sinbiota.Web.Models
{
    public class JsonMessage
    {
        public bool Success;
        public string Message;
        public string Header;
        public object Data;
        public int Milliseconds;
        private const int DefaultTimeInMilliSeconds = 5000;
        private JsonMessage(bool success, string message, string header, object data, int msecs = 0)
        {
            Success = success;
            Message = message;
            Header = header;
            Data = data;
            Milliseconds = msecs > 0 ? msecs : DefaultTimeInMilliSeconds;
        }

        public static JsonMessage InformationMessage(string message, object data = null, int msecs = 0)
        {
            return new JsonMessage(true, message, Strings.Message + ": " + DateTime.Now, data, msecs);
        }
        public static JsonMessage ErrorMessage(string message, object data = null, int msecs = 0)
        {
            return new JsonMessage(false, message, Strings.ErrorMessage + ": " + DateTime.Now, data, msecs);
        }
    }
}